#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
'''
@author: yuejl
@application:
@contact: lewyuejian@163.com
@file: api_f_book_load_conf.py
@time: 2021/11/21 0021 17:04
@desc:
'''
from integratior_service.controllers.common.continuous_load import loadConfPaser
from integratior_service.connector.base_obj.connector_obj import ConnectorObj

class FBookLoadConf(object):
    __instance = None
    __inited = None

    def __new__(cls, *args, **kwargs):
        if cls.__instance is None:
            cls.__instance = object.__new__(cls)
        return cls.__instance

    def __init__(self):
        if self.__inited is None:
            self.conf = self._loadConf('conf/f_book/api_f_book.ini')
            self.__inited = True

    def _loadConf(self, confFile):
        conf = loadConfPaser()
        conf.read(confFile, encoding='utf-8')
        f_bookConf = ConnectorObj()
        f_bookConf.url = conf.get('host', 'url')
        f_bookConf.init = conf.get('isInit', 'init')
        return f_bookConf